package com.tgy.bean;

/**
 * @Author: tgy
 * @Date: 2020-09-08 10:45
 */
public class Person implements Comparable<Person> {

    private Integer age;

    private String name;

    public Person(Integer age, String name) {
        this.age = age;
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }

    @Override
    public int compareTo(Person o) {

        int result = o.getName().compareTo(this.getName());

        if (result != 0) {

            return result;
        }

        return o.getAge().compareTo(this.getAge());
    }


}
